package cn.k.qo;


import lombok.Getter;
import lombok.Setter;

import java.util.List;

@Getter
@Setter
//封装分页查询数据
public class PageResult<T> {
    private int currentPage; //当前页
    private int prevPage; //上一页
    private int nextPage; //下一页
    private int totalCount; //总条数
    private int totalPage; //总页数
    private int PageSize; //每页条数
    private List<T> data; //封装当前页数据

    public PageResult(int currentPage, int totalCount, int pageSize, List<T> data) {
        this.currentPage = currentPage;
        this.totalCount = totalCount;
        PageSize = pageSize;
        this.data = data;

        totalPage=this.totalCount%this.PageSize==0
                ?this.totalCount/this.PageSize : this.totalCount/this.PageSize+1;
        prevPage=this.currentPage-1 >=1 ? this.currentPage-1 :1;
        nextPage=this.currentPage+1 <=this.totalPage ?this.currentPage+1 :this.totalPage;

    }

    public PageResult() {
    }
}
